package main

import "fmt"

func main() {
	fmt.Println(bestTiming([]int{7, 1, 5, 3, 6, 4}))
}

func bestTiming(prices []int) int {
	res := 0
	for i, price := range prices {
		for j := i; j < len(prices); j++ {
			res = max(res, prices[j]-price)
		}
	}
	return res
}
